package com.dcrzl.shcz.module.sys.controller;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import com.dcrzl.shcz.common.entity.sys.SysRoleGov;
import com.dcrzl.shcz.common.utils.BaseController;
import com.dcrzl.shcz.common.utils.PageInfo;
import com.dcrzl.shcz.common.utils.Result;
import com.dcrzl.shcz.module.sys.service.SysRoleGovService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @author dcrzl
 * @email 1728795786@qq.com
 * @date 2025-01-04 20:29:51
 */
@RestController
@RequestMapping("/sys/role/gov")
public class SysRoleGovController extends BaseController {
    @Autowired
    private SysRoleGovService sysRoleGovService;

    /**
     * 列表
     */
    @GetMapping("/list")
    public Result<List<SysRoleGov>> list(SysRoleGov sysRoleGov) {
        sysRoleGov.setRoleId(this.getRoleId());
        return sysRoleGovService.selectList(sysRoleGov);
    }

    /**
     * 列表分页
     */
    @GetMapping("/page")
    public PageInfo<SysRoleGov> page(SysRoleGov sysRoleGov) {
        return sysRoleGovService.selectPage(sysRoleGov);
    }

    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    public Result<SysRoleGov> info(@PathVariable("id") Long id) {
        return sysRoleGovService.selectById(id);
    }


    /**
     * 保存
     */
    @PostMapping("/save")
    public Result<Integer> save(@RequestBody SysRoleGov sysRoleGov) {
        return sysRoleGovService.insert(sysRoleGov);
    }

    /**
     * 修改
     */
    @PutMapping("/update")
    public Result<Integer> update(@RequestBody SysRoleGov sysRoleGov) {
        return sysRoleGovService.updateById(sysRoleGov);
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete")
    public Result<Integer> delete(@RequestBody Long[] ids) {
        return sysRoleGovService.deleteBatchIds(Arrays.asList(ids));
    }

}
